package per.com.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * Created by wubihang on 2018/11/19.
 */
public class DateUtils {

    public static Date formatHomeDateStart() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String dateStr = sdf.format(date);
        try {
            Date startDate = sdf.parse(dateStr);
            return startDate;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return date;
    }

    public static Date formatHomeDateEnd() {
        Date date = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        try {
            String currentDateStr = sdf.format(date);
            Date nowDate = sdf.parse(currentDateStr);
            Calendar calendar = Calendar.getInstance();
            calendar.setTime(nowDate);
            calendar.add(Calendar.DAY_OF_MONTH,+1);
            Date endDate = calendar.getTime();
            return endDate;
        } catch (ParseException e) {
            e.printStackTrace();
            return new Date();
        }
    }
}
